#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <string.h>
#include <errno.h>


int main()
{
	int shmid = 0;
	int ret;
	char *buf;
	
	shmid = shm_open("beyond", O_RDWR | O_CREAT, 0644);
	printf("shmid=%d\n", shmid);

	ret = ftruncate(shmid,sizeof(char)*1024);
	if(ret == -1)
		printf("ftruncate error\n");

	//write(shmid, "abcdefghijklmnopqrstuvwsyz", 30);

	buf = mmap(NULL, 1024, PROT_READ | PROT_WRITE, MAP_SHARED, shmid, 0);
	printf("map result %s\n", strerror(errno));

	strncpy(buf, "abcdefghijklmnopqrstuvwsyz", 30);

	close(shmid);

	return 0;
}
